package com.suixun.controller;

import com.suixun.controller.base.BaseController;
import com.suixun.domain.CaseDisplay;
import com.suixun.service.CaseDisplayService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/caseDisplay")
public class CaseDisplayController extends BaseController {

    @Resource
    private CaseDisplayService caseDisplayService;

    /**
     * 分页查询案例展示
     * @param title
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/page/{page}/{size}")
    public Object pageExclusionContent(String title, @PathVariable Integer page, @PathVariable Integer size, Integer isShow) {
        return success(caseDisplayService.pageExclusionContent(page, size, title, isShow));
    }

    /**
     * 获取指定案例详情
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    public Object getById(@PathVariable Integer id) {
        return success(caseDisplayService.getById(id));
    }

    @PostMapping("/add")
    public Object insertCaseDisplay(CaseDisplay caseDisplay, Boolean isTop) {
        caseDisplayService.insertCaseDisplay(caseDisplay, isTop);
        return success();
    }

    @PostMapping("/update")
    public Object updateCaseDisplay(CaseDisplay caseDisplay, Boolean isTop) {
        caseDisplayService.updateCaseDisplay(caseDisplay, isTop);
        return success();
    }

    @PostMapping("/delete")
    public Object deleteCaseDisplay(String ids) {
        caseDisplayService.deleteCaseDisplay(ids);
        return success();
    }
}
